package ru.amse.tsyganov.jumleditor.view.lines;

import ru.amse.tsyganov.jumleditor.view.ConnectionPoint;

public class ToConnectionPointLine extends Line {
	
	private ConnectionPoint connectionPoint;
	
	private int coordinate;
	
	private boolean isHorizontal;
	
	public ToConnectionPointLine(ConnectionPoint p, boolean isHorizontal, int cord) {
		this.connectionPoint = p;
		this.coordinate = cord;
		this.isHorizontal = isHorizontal;
	}

	public int getX1() {
		return isHorizontal ? coordinate : connectionPoint.getCpX();
	}

	public int getY1() {
		return isHorizontal ? connectionPoint.getCpY() : coordinate;
	}
	
	public int getX2() {
		return connectionPoint.getCpX();
		
	}

	public int getY2() {
		return connectionPoint.getCpY();
	}

	public void setX1(int x1) {
		if (isHorizontal) {
			coordinate = x1;
		} else {
			throw new UnsupportedOperationException();
		}
	}
	
	public void setY1(int y1) {
		if (isHorizontal) {
			throw new UnsupportedOperationException();
		} else {
			coordinate = y1;
		}
	}

	public void setX2(int x2) {
		throw new UnsupportedOperationException();	
	}

	public void setY2(int y2) {
		throw new UnsupportedOperationException();
	}

	public boolean isHorizontal() {
		return isHorizontal;
	}

}
